package com.zm.Study08_FileReader_FileWriter;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

/**
 * FileReader，FileWriter分别继承自InputStreamReader，和OutputStreamWriter
 * 他们的构造都是可以传入string类型的文件名
 */
public class FileReader_FileWriter {

    public static void main(String[] args) throws IOException {
        FileReader fr=new FileReader("D:\\project\\IDEAPROJECT\\JavaIO\\src\\main\\resources\\static\\ReaderAndWriter\\FileReader.txt");
        FileWriter fw=new FileWriter("D:\\project\\IDEAPROJECT\\JavaIO\\src\\main\\resources\\static\\ReaderAndWriter\\FileWriter.txt");
     /*   int ch;
        while ((ch=fr.read())!=-1){
            fw.write((char)ch);
        }*/
        char[] chars=new char[1024];
        int len;
        while ((len=fr.read(chars))!=-1){
            fw.write(new String(chars,0,len));
        }
        fr.close();
        fw.close();
    }
}
